<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.infodms.dms.common.Constant"%>
<%@ page import="com.infodms.dms.util.CommonUtils"%>
<%@ page import="com.infodms.dms.po.TtDealerActualSalesPO"%>
<%@ page import="com.infodms.dms.po.TtCustomerPO"%>
<%@taglib uri="/jstl/cout" prefix="c"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.List"%>
<%
	String contextPath = request.getContextPath();
    List linkManList = (List)request.getAttribute("linkManList");  		//其他联系人
	String fleet_name = (String)request.getAttribute("fleet_name");		//集团客户名称
	String contract_no = (String)request.getAttribute("contract_no");	//集团客户合同名称
	if(null == fleet_name || "".equals(fleet_name)){
		fleet_name = " ";
		contract_no = " ";
	}
	Map<String,Object> vehicleInfo = (Map<String,Object>)request.getAttribute("vehicleInfo");
	String vehicleId = vehicleInfo.get("VEHICLE_ID").toString();
	String isOldCtm = "";
	String orderId = "";
	if(null != vehicleInfo && vehicleInfo.size()>0){
		isOldCtm = vehicleInfo.get("IS_OLD_CTM")+"";//保存后：新/老客户
		orderId = vehicleInfo.get("ORDER_ID")+"";   //实销ID
	}
	
	TtDealerActualSalesPO salesInfo = (TtDealerActualSalesPO)request.getAttribute("salesInfo");//车辆实销信息
	int isFleet = 0;
	int IsOldCtm = 0;
	int IsFleet = 0;
	Long ctmId_Old = new Long(0);
	if(null != salesInfo && !"".equals(salesInfo)){
		isFleet = salesInfo.getIsFleet();	 //是否是集团客户
		ctmId_Old = salesInfo.getCtmId();	 //客户ID:如果客户id不为0，说明已做了“保存”，页面点击“保存按钮”，后台进行修改操作，否则新增
		IsOldCtm = salesInfo.getIsOldCtm();  //用户保存时的新/老客户
		IsFleet = salesInfo.getIsFleet();	 //是否是集团客户
	}
	TtCustomerPO customerInfo = (TtCustomerPO)request.getAttribute("customerInfo");//客户信息
	Long province__ = new Long(0);			  //省
	Long city__ = new Long(0);	  			  //市
	Long town__ = new Long(0);	  			  //县
	int ctmType = 0;			  			  //客户类型
	int s_ctmType = Constant.CUSTOMER_TYPE_02;//客户类型：公司客户
	int yes = Constant.IF_TYPE_YES;			  //"是"
	String oldflag = Constant.IS_OLD_CTM_02+"";
	if(null != customerInfo && !"".equals(customerInfo)){
		province__ = customerInfo.getProvince();
		city__ = customerInfo.getCity();
		town__ = customerInfo.getTown();
		ctmType = customerInfo.getCtmType();
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<script type="text/javascript">
	function doInit(){
		loadcalendar();   //初始化时间控件
		var ctmType = '<%=ctmType%>';
		var s_ctmType = '<%=s_ctmType%>';
		if(ctmType == s_ctmType){
			document.getElementById("company_table").style.display = "inline";
			document.getElementById("customerInfoid").style.display = "none";
		}else{
			document.getElementById("company_table").style.display = "none";
		}
		var IsOldCtm = '<%=IsOldCtm%>';
		if(IsOldCtm == '<%=oldflag%>'){
			document.getElementById("sel_cus_type_old").checked=true;
			showCustSel(IsOldCtm);
		}

		var isFleet = '<%=isFleet%>';//是否是集团客户
		var yes = '<%=yes%>';
		if(isFleet == yes){
			document.getElementById("is_fleet_show").style.display = "inline";
		}
	}

</script>

<title>实销信息上报</title>
</head>
<body onunload='javascript:destoryPrototype();'>
<div class="wbox">
<div class="navigation"><img src="<%=contextPath%>/img/nav.gif" />&nbsp;当前位置： 整车销售 &gt; 客户信息管理 &gt; 实销信息上报</div>
<form id="fm" name="fm" method="post"><input type="hidden" name="curPage" id="curPage" value="1" /> <input type="hidden" id="dlrId" name="dlrId" value="" />
<table class="table_edit" align=center>
	<tr class="tabletitle">
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />车辆资料</th>
	</tr>
	<tr>
		<td width="15%" align=right>VIN：</td>
		<td align=left>${vehicleInfo.VIN }</td>
		<td align=right>发动机号：</td>
		<td align=left>${vehicleInfo.ENGINE_NO }</td>
	</tr>
	<tr>
		<td align=right>车系：</td>
		<td align=left>${vehicleInfo.SERIES_NAME }</td>
		<td align=right>车型：</td>
		<td align=left>${vehicleInfo.MODEL_NAME }</td>
	</tr>
	<tr>
		<td align=right>物料代码：</td>
		<td align=left>${vehicleInfo.MATERIAL_CODE }</td>
		<td align=right>物料名称：</td>
		<td align=left>${vehicleInfo.MATERIAL_NAME }</td>
	</tr>
	<tr>
		<td align=right>颜色：</td>
		<td align=left>${vehicleInfo.COLOR }</td>
		<td align=right>&nbsp;</td>
		<td align=left>&nbsp;</td>
	</tr>
	<tr class="tabletitle">
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />销售信息</th>
	</tr>
	<tr>
		<td align="right">车牌号：</td>
		<td width="35%" align="left">${salesInfo.vehicleNo }</td>
		<td width="15%" align="right">合同编号：</td>
		<td width="35%" align="left">${salesInfo.contractNo }</td>
	</tr>
	<tr>
		<td align="right">开票日期：</td>
		<td align="left">
		<%
			if(null != salesInfo.getInvoiceDate() && !"".equals(salesInfo.getInvoiceDate())){
				out.print(CommonUtils.printDate(salesInfo.getInvoiceDate()));
			}	
		%>	 
		</td>
		<td align="right">发票编号：</td>
		<td align="left">${salesInfo.invoiceNo }</td>
	</tr>
	<tr>
		<td align="right">保险公司：</td>
		<td align="left">${salesInfo.insuranceCompany }</td>
		<td align="right">保险日期：</td>
		<td align="left">
		<%
			if(null != salesInfo.getInvoiceDate() && !"".equals(salesInfo.getInvoiceDate())){
				out.print(CommonUtils.printDate(salesInfo.getInsuranceDate()));
			}	
		%>	 	
		</td>
	</tr>
	<tr>
		<td align="right">车辆交付日期：</td>
		<td align="left">
		<%
			if(null != salesInfo.getInvoiceDate() && !"".equals(salesInfo.getInvoiceDate())){
				out.print(CommonUtils.printDate(salesInfo.getConsignationDate()));
			}	
		%>		
		</td>
		<td align="right">交付时公里数：</td>
		<td align="left">${salesInfo.miles }</td>
	</tr>
	<tr>
		<td align="right">付款方式：</td>
		<td align="left" >
		<script>document.write(getItemValue(${salesInfo.payment}));</script>	
		</td>
		<td align="right">价格：</td>
		<td align="left">
			<script>document.write(numberFormat('#,###.00',${salesInfo.price }));</script>
		</td>
	</tr>
	<tr>
		<td align="right">车辆性质：</td>
		<td colspan="2" align="left">
			<script>document.write(getItemValue(${salesInfo.carCharactor}));</script>
		</td>
		<td align="left">&nbsp;</td>
	</tr>
	<tr>
		<td align="right">备注：</td>
		<td colspan="2" align="left">${salesInfo.memo }</td>
		<td align="left">&nbsp;</td>
	</tr>
</table>
<table class="table_edit" align="center" id="customer_type_table">
	<tr class="tabletitle">
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />客户类型</th>
	</tr>
	<tr>
		<td width="15%" align=right id="select_ctm_type_id">客户类型：</td>
		<td width="35%" align="left" id="select_ctm_type_id_1">
		<script>document.write(getItemValue(${customerInfo.ctmType}));</script>			
		</td>
		<td width="15%" align="right">是否集团客户：</td>
		<td width="35%" align="left">
			<script>document.write(getItemValue(${salesInfo.isFleet}));</script>		
		</td>
	</tr>
	<tbody id="is_fleet_show" style="display: none;">
		<tr>
			<td align="right">集团客户名称：</td>
			<td align="left">
				<%
				out.println(fleet_name);
				%>
			</td>
			<td align="right">集团客户合同：</td>
			<td align="left">
				<%
				out.println(contract_no);
				%>
			</td>
		</tr>
	</tbody>
</table>
<table class="table_edit" align="center" id="company_table">
	<tr class="tabletitle">
		<th colspan="4" align="right"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />公司客户信息</th>
	</tr>

	<tr>
		<td width="15%" align="right">公司名称：</td>
		<td width="35%" align="left">${customerInfo.companyName }</td>
		<td width="15%" align="right">公司简称：</td>
		<td width="35%" align="left">${customerInfo.companySName }</td>
	</tr>
	<tr>
		<td align="right">公司电话：</td>
		<td align="left">${customerInfo.companyPhone }</td>
		<td align="right">公司规模 ：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.levelId}));</script>				
		</td>
	</tr>
	<tr>
		<td align="right">公司性质：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.kind}));</script>		
		</td>
		<td align="right">目前车辆数：</td>
		<td align="left">${customerInfo.vehicleNum }</td>
	</tr>
		<tr>
		<td align="right">客户来源：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.ctmForm}));</script>		
		</td>
	</tr>
	<tr>
		<td align="right">所在地：</td>
		<td colspan="3" align="left">
		省份：<script type='text/javascript'>
     			writeRegionName(${customerInfo.province });
 			</script>
	&nbsp;&nbsp;&nbsp;
		地级市：<script type='text/javascript'>
     			writeRegionName(${customerInfo.city });
 			</script>&nbsp;&nbsp;&nbsp;
		区、县 :<script type='text/javascript'>
     			writeRegionName(${customerInfo.town });
 			</script>&nbsp;&nbsp;&nbsp;
		</td>
	</tr>
</table>
<div id="customerInfoid">
<table class="table_edit" align="center" id="ctm_table_id">
	<tr>
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />个人客户信息</th>
	</tr>
	<tr>
		<td width="15%" align="right" id="tcmtd">客户姓名：</td>
		<td width="35%" align="left">
		${customerInfo.ctmName }
		</td>
		<td width="15%" align="right" id="sextd">性别：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.sex}));</script>			
		</td>
	</tr>
</table>
<table class="table_edit" align="center" id="ctm_table_id_2">
	<tr>
		<td width="15%" align="right">证件类别：</td>
		<td width="35%" align="left">
		<script>document.write(getItemValue(${customerInfo.cardType}));</script>				
		</td>
		<td width="15%" align="right">证件号码：</td>
		<td width="35%" align="left">${customerInfo.cardNum }</td>
	</tr>
	<tr>
		<td align="right">主要联系电话：</td>
		<td align="left">${customerInfo.mainPhone }</td>
		<td align="right">其他联系电话：</td>
		<td align="left">${customerInfo.otherPhone }</td>
	</tr>
	<tr>
		<td align="right">电子邮件：</td>
		<td align="left">${customerInfo.email }</td>
		<td align="right">邮编：</td>
		<td align="left">${customerInfo.postCode }</td>
	</tr>
	<tr>
		<td align="right">出生年月：</td>
		<td align="left">
		<%if(null != customerInfo){
			if(null != customerInfo.getBirthday() && !"".equals(customerInfo.getBirthday())){
				out.print(CommonUtils.printDate(customerInfo.getBirthday()));
			}	
		}	
		%>			
		</td>
		<td align="right">了解途径：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.ctmForm}));</script>				
		</td>
	</tr>
	<tr>
		<td align="right">家庭月收入：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.income}));</script>			
		</td>
		<td align="right">教育程度：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.education}));</script>				
		</td>
	</tr>
	<tr>
		<td align="right">所在行业：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.industry}));</script>			
		</td>
		<td align="right">婚姻状况：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.isMarried}));</script>	
		</td>
	</tr>
	<tr>
		<td align="right">职业：</td>
		<td align="left">
		<script>document.write(getItemValue(${customerInfo.profession}));</script>		
		</td>
		<td align="right">职务：</td>
		<td align="left">${customerInfo.job }</td>
	</tr>
	<tr>
		<td align="right">购买用途：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesInfo.salesAddress}));</script>		
		</td>
		<td align="right">购买原因：</td>
		<td align="left"><script>document.write(getItemValue(${salesInfo.salesReson}));</script></td>
	</tr>
	<tr>
		<td align="right">所在地：</td>
		<td colspan="3" align="left">
		省份：<script type='text/javascript'>
     			writeRegionName(${customerInfo.province });
 			</script>
	&nbsp;&nbsp;&nbsp;
		地级市：<script type='text/javascript'>
     			writeRegionName(${customerInfo.city });
 			</script>&nbsp;&nbsp;&nbsp;
		区、县 :<script type='text/javascript'>
     			writeRegionName(${customerInfo.town });
 			</script>&nbsp;&nbsp;&nbsp;
		</td>
	</tr>
	
	<tr>
		<td align="right">详细地址：</td>
		<td colspan="3" align="left">${customerInfo.address }</td>
	</tr>
</table>
</div>
<%
	if(null != linkManList && linkManList.size()>0){
%>
<table class="table_list">
    <tr align="left">
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />其他联系人信息</th>
	</tr>
    <tr >
      <th width="15%">姓名</th>
      <th width="20%">主要联系电话</th>
      <th width="20%">其他联系电话</th>
      <th width="45%">联系目的</th>
    </tr>
   <c:forEach items="${linkManList}" var="linkManList">
  		<tr class = "table_list_row1">
       		<td >${linkManList.NAME }</td>
       		<td >${linkManList.MAIN_PHONE }</td>
       		<td >${linkManList.OTHER_PHONE }</td>
       		<td >${linkManList.CONTRACT_REASON }</td>
     	</tr>
  	</c:forEach>
 </table>
 <%
	}
 %>
</form>
</div>

<script type="text/javascript">
	
	function is_fleet_Sel(){
		document.getElementById("is_fleet_show").style.display = "inline";
		document.getElementById("company_table").style.display = "none";
		document.getElementById("ctm_table_id").style.display = "none";
		document.getElementById("ctm_table_id_2").style.display = "none";
		document.getElementById("iframediv").style.display = "none";
		document.getElementById("select_ctm_type_id").disabled =true;
		document.getElementById("select_ctm_type_id_1").disabled =true;
	}
	
	function showCustSel(status){
		if(status.value == "<%=oldflag%>" || status == "<%=oldflag%>"){
			document.getElementById("showCustomerListID").disabled =false;
			document.getElementById("select_ctm_type_id").disabled =true ;
			document.getElementById("select_ctm_type_id_1").disabled =true ;
			document.getElementById("company_table").disabled =true;
			document.getElementById("ctm_table_id_2").disabled =true;
			document.getElementById("ctm_name").disabled =true;
			document.getElementById("tcmtd").disabled =true;
			document.getElementById("sex").disabled =true;
			document.getElementById("sextd").disabled =true;
		}else{
			document.getElementById("showCustomerListID").disabled =true;
			document.getElementById("select_ctm_type_id").disabled =false;
			document.getElementById("select_ctm_type_id_1").disabled =false;
			document.getElementById("company_table").disabled =false;
			document.getElementById("ctm_table_id_2").disabled =false;
			document.getElementById("ctm_name").disabled =false;
			document.getElementById("tcmtd").disabled =false;
			document.getElementById("sex").disabled =false;
			document.getElementById("sextd").disabled =false;
		}
		queryOtherLinkMan("");
	}

	function goback(){
		window.location.href = "<%=request.getContextPath()%>/sales/customerInfoManage/SalesReport/salesReportInit.do";
	}
	
	function objToStr(itemValue){
		itemValue = itemValue==null?"":itemValue;
		itemValue = itemValue=='null'?"":itemValue;
		return itemValue;
	}

	
</script>
</body>
</html>